from django.contrib import admin
from django import forms
from profiles.models import Reporter, Article, Comment, Vocabulary, Category
from profiles.models import Poll, Choice, File, University, Institution
from profiles.models import About, Contact, Banner, About_toefl
from ckeditor.widgets import CKEditorWidget

#class PostAdminForm(forms.ModelForm):
#    content = forms.CharField(widget=CKEditorWidget())
#    class Meta:
#        model = Article
#
#class PostAdmin(admin.ModelAdmin):
#    form = PostAdminForm

class CommentAdmin(admin.ModelAdmin):
    display_fields = ["post", "author", "created"]

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3 
    
class PollAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,                  {'fields': ['question']}),
        ('Date information',    {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]
    inlines = [ChoiceInline]
    
    list_display = ('question', 'pub_date', 'was_published_today')
    list_filter = ['pub_date']
    search_fields = ['question']
    date_hierarchy = 'pub_date'

admin.site.register(Reporter)
admin.site.register(Article)
admin.site.register(Category)
admin.site.register(Comment)
admin.site.register(Vocabulary)
admin.site.register(Poll, PollAdmin)
admin.site.register(File)
admin.site.register(University)
admin.site.register(Institution)
admin.site.register(About)
admin.site.register(Contact)
admin.site.register(Banner)
admin.site.register(About_toefl)